import { useUserStore } from "@/store/model/user";
import router from "@/router/index";
export function loginout(before?: () => void, after?: () => void) {
    // console.log("进来退出登录方法");
  before && before();//执行函数
  const userStore = useUserStore();
  localStorage.removeItem("token");
  // 清仓库数据
  userStore.updateMenus([]);
  userStore.username = "";
  // 清空动态路由
  const allroutes = router.getRoutes();
  allroutes.forEach((item) => {
    if (item.name !== "login" && item.name) {
      router.removeRoute(item.name);
    }
  });
  //回到登录页
  router.push("/login");
  after && after();
}
